﻿using System.Web.Mvc;
using Microsoft.Practices.Unity;
using SchoolProject2012.Services;
using SchoolProject2012.Factories;
using SchoolProject2012.Areas.ChargeDePlacement.Controllers;

namespace SchoolProject2012.Areas.ChargeDePlacement
{
    public class ChargeDePlacementAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "ChargeDePlacement";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "ChargeDePlacement_default",
                "ChargeDePlacement/{controller}/{action}/{id}",
                new {controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

            var container = new UnityContainer();
            container.RegisterType<IModelService, ModelService>();
            container.RegisterType<IController, EntrepriseController>("Entreprise");
            container.RegisterType<IController, ContactController>("Contact");
            container.RegisterType<IController, EleveController>("Eleve");

            var factory = new UnityControllerFactory(container);
            ControllerBuilder.Current.SetControllerFactory(factory);
        }
    }
}
